import { Module } from 'vuex';
import { BackEndRoutesState, RootStateTypes } from '@/store/interface';
import { RouteRecordRaw } from 'vue-router';

const backEndRoutesModule: Module<BackEndRoutesState, RootStateTypes> = {
	namespaced: true,
	state: {
		backEndRoutes: [],
	},
	mutations: {
		// 后端控制路由
		getBackEndControlRoutes(state, data: Array<RouteRecordRaw>) {
			state.backEndRoutes = data;
		},
	},
	actions: {
		// 后端控制路由
		setBackEndControlRoutes({ commit }, routes: Array<RouteRecordRaw>) {
			commit('getBackEndControlRoutes', routes);
		},
	},
};

export default backEndRoutesModule;
